package com.wzm.controller;

import com.wzm.domain.Move;
import com.wzm.domain.User;
import com.wzm.domain.UserMove;
import com.wzm.service.MoveService;
import com.wzm.util.Ajaxresult;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/move")
public class MoveController {
    @Autowired
    private MoveService moveService;

    @GetMapping
    public List<Move> findAll() {
        return moveService.findAll();
    }

    @GetMapping("/{id}")
    public Move findById(@PathVariable("id") Long id) {
        return moveService.findById(id);
    }

    @PostMapping("/buy")
    public Ajaxresult buyById(@RequestBody UserMove userMove) {
            return moveService.buyById(userMove);
    }

    @PutMapping
    public Ajaxresult sendTicket(User user) {
            return moveService.sendTicket(user);
    }

    @GetMapping("/watch/{id}")
    public Ajaxresult watch(@PathVariable Long id){
        return moveService.watch(id);
    }
}
